<%@ page import="java.io.InputStream" %>
<%@ page import="org.apache.ibatis.io.Resources" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactory" %>
<%@ page import="org.apache.ibatis.session.SqlSessionFactoryBuilder" %>
<%@ page import="org.apache.ibatis.session.SqlSession" %>
<%@ page import="cn.school.dao.StudentDao" %>
<%@ page import="cn.school.entity.Student" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.io.IOException" %><%--
  Created by IntelliJ IDEA.
  User: C
  Date: 2022/6/30
  Time: 15:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    try {
        InputStream in = Resources.getResourceAsStream("SqlSessionFactory.xml");
        SqlSessionFactory build = new SqlSessionFactoryBuilder().build(in);
        SqlSession sqlSession = build.openSession();
        StudentDao mapper = sqlSession.getMapper(StudentDao.class);
        ArrayList<Student> paging = mapper.paging(1, 10);
        out.println(paging);


        sqlSession.commit();
        sqlSession.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

%>
</br>
<%!//在这种标记中定义的变量为全局变量
    int count=0;
    synchronized void count(){
    count++;
}
%>
<%
    count();
    out.println("这是第"+count+"个访问者!");
%>
</body>
</html>
